Skip to content

Zend/zend_compile.h: use uint32_t type for zend_op_array.last_var#21543

Open
Girgias wants to merge 1 commit intophp:masterfrom
Girgias:last_var-uint32t
Open

Zend/zend_compile.h: use uint32_t type for zend_op_array.last_var#21543
Girgias wants to merge 1 commit intophp:masterfrom
Girgias:last_var-uint32t

Conversation

@Girgias
Copy link
Copy Markdown
Member

@Girgias Girgias commented Mar 27, 2026

No description provided.

@github-world192

This comment was marked as off-topic.

uint32_t level = 1 + trace_buffer[0].level;
int idx, len, i, v, vars_count, call_level;
int len, v;
uint32_t idx, i, vars_count, call_level;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems quite inconsistent, the same variables are declared many times in the JIT files, and i could be local for pretty much all of them.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm happy to make the i variable local, wasn't sure if I should or not.

/* We iterate the variables backwards, so we can eliminate sequences like INIT_ROPE
* and INIT_ARRAY. */
for (i = ssa->vars_count - 1; i >= op_array->last_var; i--) {
for (i = ssa->vars_count - 1; i >= (int)op_array->last_var; i--) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😕 This this warn? That's pretty error prone.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was breaking opcache, not sure why.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because C integer coercion semantics are wonky. int gets coerced to unsigned, which breaks the >= check when op_array->last_var == 0.

int i;
for (i = 0; i < op_array->last_var; i++) {
if (zend_string_equals(op_array->vars[i], var_name)) {
for (uint32_t j = 0; j < op_array->last_var; j++) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand the switch in variable name here. There's no surrounding i?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was getting a shadowing warning. I'll double check.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants